﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Collections;
using WorkBasket.Api;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Primitives;
using System.ComponentModel.Composition.ReflectionModel;

namespace WorkBasket.ExtensionFactory
{

  
    public static class Factory
    {
        static private CompositionContainer _container;

        static public Extensions Extensions;

        public static void Init(string Path)
        {

            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }

            //Create an assembly catalog of the assemblies with exports
            var catalog = new AggregateCatalog(
                new DirectoryCatalog(Path, "*.dll"));

            //Create a composition container
            _container = new CompositionContainer(catalog);

            Extensions = new Extensions();
            _container.ComposeParts(Extensions);

        }

 

    }

    public class Extensions
    {

        [ImportMany(typeof(IAction))]
         public IEnumerable<IAction> Actions;

        [ImportMany(typeof(IControl))]
         public IEnumerable<IControl> Controls;
    }



}
